package com.lxg.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

/**
 * @author 陆小根
 * date: 2022/04/27
 * Description:
 */

public class MyBatisConfig {

  @Bean
  public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource) {
    SqlSessionFactoryBean ssbf = new SqlSessionFactoryBean();
    ssbf.setTypeAliasesPackage("com.lxg.domain");
    ssbf.setDataSource(dataSource);
    return ssbf;
  }

  @Bean
  public MapperScannerConfigurer mapperScannerConfigurer() {
    MapperScannerConfigurer msc = new MapperScannerConfigurer();
    msc.setBasePackage("com.lxg.dao");
    return msc;
  }

}
